const path = require('path')
// 导入在内存中生成页面的插件
const html = require('html-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')


module.exports = {
    entry: './src/index.js',
    mode: 'development', // 开发模式: development  ;  生产模式: production
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js'
    },
    devtool: 'inline-source-map',
    module: {
        rules: [
            { test: /\.vue$/, use: 'vue-loader' },
            { test: /\.css$/, use: ['style-loader', 'css-loader'] },
            { test: /\.scss$/, use: ['style-loader', 'css-loader', 'sass-loader'] },
            {
                test: /\.(jpg|png|bmp|jpeg|gif|ico)$/, use: {
                    loader: 'file-loader',
                    options: {
                        limit: 10000,
                        name: '[name].[ext]',
                        outputPath: './img',
                        publicPath: './img'
                    }
                }
            },
            { test: /\.(ttf|woff2|woff|eot|svg|otf)$/, use: 'url-loader' }
        ]
    },
    resolve: {
        alias: {
            'vue$': 'vue/dist/vue.min.js'
        }
    },
    plugins: [
        new html({
            // 创建一个在内存中生成html页面的插件
            template: path.join(__dirname, './src/index.html'), // 指定模块页面 
            filename: "index.html",
        }),
        new VueLoaderPlugin(),

    ],

}